home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
-
- extern int peek();
- /**********************************************************************/
-
- main(quantity,parameter)
- int quantity;
- char *parameter[];
- {
- int i, drive, orig_default;
- int disk_id;
- char drive_letter;
- unsigned long int lax, lbx, lcx, ldx;
- unsigned long int disk_used, disk_size, disk_free;
- unsigned long max_block, used_block, free_block;
- struct regval {int ax,bx,cx,dx,si,di,ds,es;} srv;
-
- /************************************************************************/
- /* Written by: George H. Ford Copyright, August 1990 */
- /* Severn, Maryland 21144 */
- /* */
- /* Language: Computer Innovations CI-86 Compiler */
- /* */
- /* PUBLIC DOMAIN: Entered with source into PD as a learning tool. */
- /* */
- /* Some older computers using MS-DOS versions either did not support*/
- /* or had a problem with int21H function 36H for other than the */
- /* default drive. DX on return would be messed up, incorrect. */
- /* Therefore, the steps of this program have been set to avoid this*/
- /* problem by switching default disks then back again: */
- /* get disk from command line */
- /* get current default disk */
- /* set default to command line disk */
- /* get drive size info and type */
- /* set default back to original at start of program */
- /* */
- /* Make use of interrupt function 36H: */
- /* Entry: AH = 36H , DL = drive (0 - default, 1 = A, etc. */
- /* */
- /* Exit: AX = FFFFH on error (bad drive designator) */
- /* AX = sectors per allocation unit */
- /* BX = number of free allocation units on drive */
- /* CX = bytes per sector */
- /* DX = total number of allocation units on drive */
- /* */
- /* And interrupt function 1CH: */
- /* Entry: AH = 1CH , DL = drive (0 - default, 1 = A, etc. */
- /* */
- /* Exit: AL = number of sectors per cluster */
- /* DS:BX = segment:offset of FAT identification byte*/
- /* CX = size of physical sector (in bytes) */
- /* DX = number of clusters for drive */
- /* */
- /************************************************************************/
- srv.ax = 0x1900;
- sysint(0x21,&srv,&srv); /* perform get orig_default drive */
- orig_default = 0x00ff & srv.ax; /* drive 0 == a */
-
- srv.ax = 0x0e00;
- srv.dx = drive = 0x0000; /* dl has drive, 0 == a */
- if(quantity >= 2)
- {
- strncpy(&drive_letter, parameter[1],1);
- drive = 0x00ff & toupper(drive_letter);
- if((drive >= 'A') && (drive <= 'Z'))
- {
- drive -= 65;
- srv.dx = (0x00ff & drive);
- sysint(0x21,&srv,&srv); /* perform set new default drive */
- }
- else
- {
- printf("\n\nUSAGE: size drive_letter\b");
- printf("\n\nwhere, size == this program's runtime name");
- printf("\n drive_letter == A to Z drive designator");
- printf("\n (if absent, default drive is used)");
- goto user_msg;
- }
- }
-
-
- /* Find Size info for default drive */
- srv.ax = 0x3600; /* use interrupt 21hsubfunction 36h */
- srv.bx = 0x0000;
- srv.cx = 0x0000;
- srv.dx = 0x0000; /* use default drive */
-
- sysint(0x21,&srv,&srv);
-
- if (srv.ax == 0xFFFF)
- {
- printf(" SYSERR-INFO [SEEK ERROR]: Drive designator on size seek error.\n");
- goto aeoutprt;
- }
-
- lax = srv.ax;
- lbx = srv.bx;
- lcx = srv.cx;
- ldx = srv.dx;
-
- disk_size = ((ldx * lax ) * lcx);
- disk_free = ((lbx * lax ) * lcx);
- disk_used = disk_size - disk_free;
-
- max_block = disk_size / lcx;
- used_block = disk_used / lcx;
- free_block = disk_free / lcx;
-
-
- /* get drive FAT id to determine the type of drive */
- srv.ax = 0x1C00;
- srv.dx = 0x0000; /* use default drive */
- sysint(0x21,&srv,&srv);
- disk_id = (peek(srv.bx,srv.ds) & 0x00ff);
-
-
-
- printf("\n\n");
-
- for(i = 1; i<=80; i++) {printf("*");}
- printf("\n");
-
- printf("BYTESIZE Stat-> Disk Size: (%10ld) Used: (%10ld) Free: (%10ld)\n\n",\
- disk_size, disk_used, disk_free);
- printf("Sector Blocks-> Total Max: (%10ld) Used: (%10ld) Free: (%10ld)\n",\
- max_block, used_block, free_block);
-
- for(i = 1; i<=80; i++) {printf("-");}
-
- printf("\n");
- printf("Sectors per cluster unit (clustersize): %10ld\n",\
- lax);
- printf("Number of free cluster units on drive: %10ld\n",\
- lbx);
- printf("Number of bytes per sector, this drive: %10ld [Block Size]\n",\
- lcx);
- printf("TOTAL number of cluster units on drive: %10ld\n",\
- ldx);
- printf("\n");
-
- printf(\
- ">>>>>>>>>>>>>>>>>>>>>>>> Possible Drive Type(s) <<<<<<<<<<<<<<<<<<<<<<<<"\
- ); printf("\n");
- printf(\
- "Sec. Sec. Trk. Num. Cls. Disk Media Possible Media Tracks Per"\
- ); printf("\n"); printf(\
- "Size Trak Side Head Size ID Size Type Media Density Inch"\
- ); printf("\n"); printf(\
- "__________________________________________________________________________"\
- ); printf("\n");
-
- if(disk_size > 3500000) goto fixed_disk;
-
- switch(disk_id)
- {
- case 0x00f0:
- printf(\
- " 512 18 80 2 1 F0 1.44MB 3.5 inch HD 135"\
- ); printf("\n");
- printf(\
- " 512 18 80 2 1 F0 1.44MB 5.25 inch HD 96"\
- ); printf("\n");
- break;
- case 0x00f8:
- if( lcx == 512)
- {
- printf(\
- " 512 9 80 1 2 F8 360KB 3.5 inch SD 135"\
- ); printf("\n");
- printf(\
- " 512 9 80 1 2 F8 360KB 5.25 inch SD 96"\
- ); printf("\n");
- }
- if( lcx == 1024)
- {
- if(disk_size < 300000)
- {
- printf(\
- "1024 5 40 1 1 F8 200KB 5.25 inch SD 48"\
- ); printf("\n");
- }
- else
- {
- if(disk_size < 500000)
- {
- printf(\
- "1024 5 80 1 1 F8 400KB 5.25 inch SD 96"\
- ); printf("\n");
- printf(\
- "1024 5 80 1 1 F8 400KB 3.5 inch SD 135"\
- ); printf("\n");
- }
- else
- {
- if(disk_size < 900000)
- {
- printf(\
- "1024 5 80 2 1 F8 800KB 5.25 inch SD 96"\
- ); printf("\n");
- printf(\
- "1024 5 80 2 1 F8 800KB 3.5 inch SD 135"\
- ); printf("\n");
- }
- else
- {
- if(disk_size < 140000)
- {
- printf(\
- "1024 8 80 2 1 F8 1.28MB 5.25 inch HD 96"\
- ); printf("\n");
- }
- }
- }
- }
- }
- break;
- case 0x00f9:
- if(lcx == 512)
- {
- if(lax == 1)
- {
- if(disk_size < 800000)
- {
- printf(\
- " 512 9 80 2 1 F9 720KB 3.5 inch SD 135"\
- ); printf("\n");
- printf(\
- " 512 9 80 2 1 F9 720KB 3.5 inch SD 135"\
- ); printf("\n");
- }
- else
- {
- printf(\
- " 512 15 80 2 1 F9 1.20MB 5.25 inch HD 96"\
- ); printf("\n");
- }
- }
- if(lax == 2)
- {
- printf(\
- " 512 9 80 2 2 F9 720KB 3.5 inch SD 135"\
- ); printf("\n");
- printf(\
- " 512 9 80 2 2 F9 720KB 5.25 inch SD 96"\
- ); printf("\n");
- }
- if(lax == 4)
- {
- printf(\
- " 512 9 80 2 4 F9 720KB 5.25 inch SD 96"\
- ); printf("\n");
- }
- }
- if(lcx == 1024)
- {
- printf(\
- "1024 5 40 2 1 F9 400KB 5.25 inch SD 48"\
- ); printf("\n");
- }
- break;
- case 0x00fa:
- printf(\
- " 512 8 80 1 2 FA 320KB 3.5 inch SD 135"\
- ); printf("\n");
- printf(\
- " 512 8 80 1 2 FA 320KB 5.25 inch SD 96"\
- ); printf("\n");
- break;
- case 0x00fb:
- if(lcx == 512)
- {
- if(lax == 2)
- {
- printf(\
- " 512 8 80 2 2 FB 640KB 3.5 inch SD 135"\
- ); printf("\n");
- printf(\
- " 512 8 80 2 2 FB 640KB 5.25 inch SD 96"\
- ); printf("\n");
- }
- else
- {
- printf(\
- " 512 8 80 2 4 FB 640KB 5.25 inch SD 96"\
- ); printf("\n");
- }
- }
- if(lcx == 1024)
- {
- printf(\
- "1024 10 80 2 1 FB 1.60MB 3.5 inch HD 135"\
- ); printf("\n");
- printf(\
- "1024 10 80 2 1 FB 1.60MB 5.25 inch HD 96"\
- ); printf("\n");
- }
- break;
- case 0x00fc:
- printf(\
- " 512 9 40 1 1 FC 180KB 5.25 inch SD 48"\
- ); printf("\n");
- break;
- case 0x00fd:
- if(lax == 1)
- {
- printf(\
- " 512 9 40 2 1 FD 360KB 5.25 inch SD 48"\
- ); printf("\n");
- }
- if(lax == 2)
- {
- printf(\
- " 512 9 40 2 2 FD 360KB 5.25 inch SD 48"\
- ); printf("\n");
- }
- if(lax == 4)
- {
- printf(\
- " 128 26 77 1 4 FD 250KB 8 inch SD 48"\
- ); printf("\n");
- }
- break;
- case 0x00fe:
- if(lcx == 128)
- {
- printf(\
- " 128 26 77 1 4 FE 250KB 8 inch SD 48"\
- ); printf("\n");
- }
- if(lcx == 512)
- {
- printf(\
- " 512 8 40 1 1 FE 160KB 5.25 inch SD 48"\
- ); printf("\n");
- }
- if(lcx == 1024)
- {
- printf(\
- "1024 8 77 2 1 FE 1.23MB 5.25 inch HD 96"\
- ); printf("\n");
- printf(\
- "1024 8 77 2 1 FE 1.23MB 8 inch SD 48"\
- ); printf("\n");
- }
- break;
- case 0x00ff:
- if(disk_size < 400000)
- {
- printf(\
- " 512 8 40 2 2 FF 320KB 5.25 inch SD 48"\
- ); printf("\n");
- }
- else
- {
- printf(\
- " 512 9 80 2 2 FF 720KB 5.25 inch SD 96"\
- ); printf("\n");
- }
- break;
- default:
- printf("Drive type is indeterminate from FAT Drive ID: %04xH\n",disk_id);
- break;
- }
-
- fixed_disk:
- if(disk_size > 3500000)
- {
- printf("\n***** OTHER POSSIBLE DRIVE TYPE: Fixed Disk\n");
- }
-
-
- for(i = 1; i<=80; i++) {printf("*");}
-
- aeoutprt: /* abort on error message output printed to screen */
-
- srv.ax = 0x0e00;
- srv.dx = 0x00ff & orig_default; /* set to orig default drive */
- sysint(0x21,&srv,&srv);
-
- user_msg: /* usage message abort point */
- exit(0);
- }
-